import { RegisterComponent } from "@feng3d/ecs";
import { SkeletonHelper } from "../../thirdparty/three/imports";
import { Component3D } from "../core/Component3D";
import { Node3D } from "../core/Node3D";

declare module "@feng3d/ecs"
{
    interface ComponentMap { SkeletonHelper3D: SkeletonHelper3D; }
}

/**
 * 包装`three`中`CameraHelper`。
 */
@RegisterComponent({ name: 'SkeletonHelper3D' })
export class SkeletonHelper3D extends Component3D
{
    _helper: SkeletonHelper;

    node3D: Node3D;

    init()
    {
        super.init();
        this._helper = new SkeletonHelper(this.node3D?._group);
        this._entity._group.add(this._helper);
    }

    destroy(): void
    {
        this._entity._group.remove(this._helper);

        this._helper.dispose();
        this._helper = null;

        super.destroy();
    }
}
